FUNCTIONAL PEARL Linear, Bounded, Functional Pretty-Printing

نویسنده

  • S. DOAITSE SWIERSTRA
چکیده

We present two implementations of Oppen’s pretty-printing algorithm in Haskell that meet the efficiency of Oppen’s imperative solution but have a simpler, clear structure. We start with an implementation that uses lazy evaluation to simulate two co-operating processes. Then we present an implementation that uses higher-order functions for delimited continuations to simulate co-routines with explicit scheduling.

برای دانلود رایگان متن کامل این مقاله و بیش از 32 میلیون مقاله دیگر ابتدا ثبت نام کنید

ثبت نام

اگر عضو سایت هستید لطفا وارد حساب کاربری خود شوید

منابع مشابه

Pretty Printing with Partial Continuations

Extended Abstract A pretty printer converts tree structured data, for example the syntax tree of a program or an XML document, into nicely formatted text with a given line width limit. A pretty printing library provides the functionality common to a large class of pretty printers, thus enabling a programmer to easily implement a specific pretty printer. A pretty printing library enables the pro...

متن کامل

Functional Pearl: Replaying the stack for parsing and pretty printing

Modulo inessential details, parsers and pretty printers, to and from algebraic datatypes, offer an uncanny resemblance and yet are all too often defined separately, in gross violation of the “don’t repeat yourself” principle. We present a family of reversible parser/printer combinators that allows one to define both at once in a type-safe manner, compositionally and without any need for a prepr...

متن کامل

Pretty Printing with Delimited Continuations

Pretty printing is the task of nicely formatting tree structured data within a given line width limit. In 1980 Oppen published a pretty printing algorithm that takes time linear in the size of the input, independent of the line width, and uses only limited look-ahead. This work inspired the development of a number of purely functional pretty printing libraries in Haskell. Here I present a new f...

متن کامل

Computer Science at Kent Pretty Printing with Delimited Continuations

Pretty printing is the task of nicely formatting tree structured data within a given line width limit. In 1980 Oppen published a pretty printing algorithm that takes time linear in the size of the input, independent of the line width, and uses only limited look-ahead. This work inspired the development of a number of purely functional pretty printing libraries in Haskell. Here I present a new f...

متن کامل

Infinite Pretty-printing in eXene

We describe the design and implementation of a Standard ML of New Jersey library for the interactive pretty-printing of possibly infinite syntax trees. The library handles elision in a novel way, and is implemented using Concurrent ML and the eXene X Window System toolkit. 1 Pretty-printing with Elision In the modern approach to pretty-printing, as developed by Oppen [Opp80] and others [Mik81, ...

متن کامل

ذخیره در منابع من


  با ذخیره ی این منبع در منابع من، دسترسی به آن را برای استفاده های بعدی آسان تر کنید

عنوان ژورنال:

دوره   شماره 

صفحات  -

تاریخ انتشار 2008